import time
import logging
def Home(func):
    def inner():
        start=time.time()
        result=func()
        end=time.time()
        logger=logging.getLogger()
        fh=logging.FileHandler("sc.log",encoding='utf-8')
        ch=logging.StreamHandler()
        foematter=logging.Formatter("%(asctime)s-%(levelname)s:%(message)s")
        fh.setFormatter(foematter)
        ch.setFormatter(foematter)
        logger.addHandler(fh)
        logger.addHandler(ch)
        logger.setLevel(logging.DEBUG)
        logger.warning(f"执行了{func.__name__}函数，共花费了{end-start}秒")
        return result
    return inner


@Home
def func1():
    sum=0
    for i in range(122000000):
        sum = sum + i
    return sum
print(func1())